import java.util.Scanner;

public class fbnq {
    public static long fbnq1(int num){
        int qian = 0;
        int hou = 1;
        int sum1 = qian+hou;
        System.out.print("前"+num+"的斐波那契数分别是："+hou+" ");
        for(int i = 2;i<=num;i++){
            hou = hou+qian;
            qian = hou-qian;
            sum1 += hou;
            System.out.print(hou+" ");
        }
        System.out.println();
        return sum1;
    }
    public static void main(String[] args){
        System.out.print("请输入想知道第几个斐波那契数值：");
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        System.out.println("前"+s+"项斐波那契的和为："+fbnq1(s));
    }
}
